package com.xc.stock.domain.basic.convert;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author rplees
 * @email rplees.i.ly@gmail.com
 * @version 1.0
 * @created Jan 6, 2021 4:37:30 PM
 */
public interface IEntityPOConvert<E, P> {
	final static String[] EMPTY_PROPERTIES = new String[] { };
	
	E toEntity(P d);

	P toPo(E e);
	
	default String[] ignoreProperties() {
		return EMPTY_PROPERTIES;
	}
	
	default List<E> toEntity(List<P> e) {
		return e.stream().map(v -> toEntity(v)).collect(Collectors.toList());
	}

	default List<P> toPo(List<E> e) {
		return e.stream().map(v -> toPo(v)).collect(Collectors.toList());
	}
}
